//
// Created by Langingsing on 2021/5/26.
// command.h

#ifndef MAIN_C_COMMAND_H
#define MAIN_C_COMMAND_H

#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include "debugging.h"

#define CMP_FILE_CAPACITY 10

struct alist
{
    struct alist *next;
    char *alias;
};

typedef struct alist alist;

struct opt_t
{
    alist *ahead;
    int symbol;
};

typedef struct opt_t opt_t;

struct Data
{
    // source file names
    char *comparingFileNames[CMP_FILE_CAPACITY];

    // destination file name
    char *destFileName;

    // number of actual file
    int fileCnt;

    // limit when printing
    int limit;

    // is this structure variable valid
    bool isValid;

    // options got from cmd
    bool toggles[26];

    opt_t optMenu[32]; // support 32 options
};

void clearFileNames(struct Data *pData);

//void old_setToggle(struct Data *pData, int mode);

int setToggle(struct Data *pData, const char *currCmd);

void showToggles(struct Data *pData);

void showData(struct Data *pData);

FILE *openDestFile(const char *_destFileName);

int parseCommands(struct Data *pData, int argc, char *argv[]);

void instruction(void);

void init(struct Data *pData);

//int parseInt_safe(const char *str);

bool canAccess(const char *str);

bool isNumber(const char *str);

void setFileNames(struct Data *pData, char *currentCmd);

void clearToggles(struct Data *pData);

//void old_solveConflicts(struct Data *pData, int mode);

int solveConflicts(struct Data *pData);

bool isValidFileName(const char *str);

#endif //MAIN_C_COMMAND_H
// command.h
